package com.twschool.practice.guessnumber;

import java.util.ArrayList;

public class Answer {

    private String generateInput;
    private String userInput;
    private String result;
    public Answer(String generateInput) {
        setGenerateInput(generateInput);
    }

    public String check() {

        int Bsum = 0;
        int Asum = 0;
        for (int i = 0;i<4;i++){
            if (generateInput.substring(i,i+1).equals(userInput.substring(i,i+1))){
                Asum++;
            }else if (generateInput.contains(userInput.substring(i,i+1))) {
                Bsum++;
            }
        }
        result = Asum+"A"+Bsum+"B";
        return result;
    }

    public String getUserInput() {
        return userInput;
    }

    public void setUserInput(String userInput) {
        this.userInput = userInput;
    }

    public String getGenerateInput() {
        return generateInput;
    }

    public void setGenerateInput(String generateInput) {
        this.generateInput = generateInput;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }
}
